import {request} from './requess'

// 首页数据请求
export const getHomeList = () => {
  return request({url: '/index/index', method: 'get'})
}

// 搜索弹出框的数据请求
export const getSearchList = () => {
  return request({url: '/search/index', method: 'get'})
}

// 输入框实时搜索功能
export const getSearchTipsListData= (keyword) => {
  return request({url: '/search/helper', method: 'get', params: {keyword}})
}

// 搜索框商品搜索
export const getGoodsList = (keyword,page,size,order,categoryId,sort) => {
  return request({url: '/goods/list', method: 'get', params: {keyword,page,size,order,categoryId,sort}})
}

// 清楚历史记录
export const delHistory = () => {
  return request({url: '/search/clearhistory', method: 'post'})
}

// 用户登录
export const login = (username,pwd) => {
    return request({ url: '/auth/loginByWeb', method: 'post', data: {username,pwd}})
}

// 请求商品详情数据
export const getPruductDetailList = (id) => {
    return request({ url: '/goods/detail', method: 'get', params: { id } })
}

// 获取相关产品
export const getGetGoodsRelatedlist = (id) => {
    return request({ url: '/goods/related', method: 'get', params: { id } })
}

// 获取购物车产品数量
export const getCartCount = () => {
    return request({ url: '/cart/goodscount', method: 'get', })
}

// 加入购物车
export const addCart = (goodsId, productId, number) => {
    return request({ url: '/cart/add', method: 'post', data: { goodsId, productId, number } })
}

// 获取购物车数据（含完成编辑）
export const getCartList = () => {
    return request({ url: '/cart/index', method: 'get'})
}

// 点击切换商品选中状态（含全选）
export const ChangeGoodChecked = (isChecked, productIds) => {
    return request({ url: '/cart/checked', method: 'post', data: { isChecked, productIds } })
}

// 商品步进器
export const stepperChange = (goodsId, id, number, productId) => {
    return request({ url: '/cart/update', method: 'post', data: { goodsId, id, number, productId }})
}

// 删除商品
export const delGoods = (productIds) => {
    return request({ url: '/cart/delete', method: 'post', data: { productIds } })
}

// 获取分类数据
export const getCategoryData = (id) => {
    return request({ url: '/goods/category', method: 'get', params: { id } })
}

// 分类页面商品列表请求
export const getCategoryList = (categoryId, page, size) => {
    return request({ url: '/goods/list', method: 'get', params: { categoryId, page, size } })
}

// 品牌详情
export const getBrandDetail = (id) => {
    return request({ url: '/brand/detail', method: 'get', params: {id} })
}

// 专题数据

export const getTopicData = (page, size) => {
    return request({ url: '/topic/list', method: 'get', params: { page, size } })
}

// 分类数据
export const getCatalogList = () => {
    return request({ url: '/catalog/index', method: 'get' })
}

// 获取当前分类数据
export const getCategoryContent = (id) => {
    return request({ url: '/catalog/current', method: 'get', params: {id} })
}
